//--------------------------------------------------
/**
 *
 *      Hand Gesture Recognition System
 *
 */
//--------------------------------------------------
/**
 * //CV CLASS//
 * Librería integración del WRAP de OpenCV
 *
 * @author Wilson Sarmiento & Edwin Cobos & Cesar Murcia
 * @version cv_v1.2
 *
 * Revisado: PENDIENTE
 */
//--------------------------------------------------
//PACKAGE//
package OpenCV;
//IMPORT//
/**
 * Import
 */
import com.sun.jna.Native;
import com.sun.jna.Platform;
import com.sun.jna.Structure;
import com.sun.jna.Pointer;
//--------------------------------------------------
/**
 *cv Class Integra los procesos de cvLib [{@link cvLib}] & cxcore [{@link cxcoreLib}] & highgui [{@link highguiLib}]
 * necesarios para trabajar en @see <a href="http://opencv.willowgarage.com/wiki/">OpenCV</a>
 */
public class cv {
    //Inicializar las librerias CV
    private static cvLib        cv;
    private static highguiLib   highgui;
    private static cxcoreLib    cxcore;

    /**
     * Carga libreria <b>CV</b> de OpenCV
     * @return Objeto de la clase cvLib
     */
    public static cvLib cv()
    {
        cvLib new_cv =
        (cvLib) Native.loadLibrary((Platform.isWindows() ? "cv210" : "cv"),cvLib.class);
        return new_cv;
    }

    /**
     * Carga libreria <b>HIGHGUI</b> de OpenCV
     * @return Objeto de la clase highguiLib
     */
    public static highguiLib highgui()
    {
        highguiLib new_highgui =
        (highguiLib) Native.loadLibrary((Platform.isWindows() ? "highgui210" : "highgui"),highguiLib.class);
        return new_highgui;
    }

    /**
     * Carga libreria <b>CXCORE</b> de OpenCV
     * @return Objeto de la clase cxcoreLib
     */
    public static cxcoreLib cxcore()
    {
        cxcoreLib new_cxcore =
        (cxcoreLib) Native.loadLibrary((Platform.isWindows() ? "cxcore210" : "cxcore"), cxcoreLib.class);
        return new_cxcore;
    }

    /**
     * Inicializa la libreria CXCORE
     * @return true si encuentra la libreria
     */
    public static boolean loadCxcore()
    {
        cxcore = cxcore();
        return cxcore != null;
    }

    /**
     * Inicializa la libreria CV
     * @return true si encuentra la libreria
     */
    public static boolean loadCv()
    {
        cv = cv();
        return cv != null;
    }

    /**
     * Inicializa la libreria HIGHGUI
     * @return true si encuentra la libreria
     */
    public static boolean loadHighgui()
    {
        highgui = highgui();
        return highgui != null;
    }
    //------------------------------------------
    //--- ESTRUCTURAS OPENCV
    //------------------------------------------

    /**
     * Estructura que contiene el ancho y alto de un rectangulo
     * @see <a href="http://opencv.willowgarage.com/documentation/c/core_basic_structures.html#CvSize">Mas Info</a>
     */
    public static class Size extends Structure
            implements Structure.ByValue
    {
        public int width;
        public int height;
        public Size(int w,int h)
        {            
            width = w;
            height = h;
            write(); 
        }
    }   
    //----cvMat
    /**
     * Estructura que contiene una matriz multi-canal
     * @see <a href="http://opencv.willowgarage.com/documentation/c/core_basic_structures.html#index-8476">Mas Info</a>
     */
    public static class Mat extends Structure
            implements Structure.ByReference
    {
        public int type;
        public int step;
        public long refcount;
        public long data;
        public int rows;
        public int cols;        
    }

    /**
     * Inicializa el objeto Mat y prepara el espacio para la matriz
     * @see <a href="http://opencv.willowgarage.com/documentation/c/core_operations_on_arrays.html#index-8604">Mas Info</a>
     * @param rows  Numero de filas de la matriz
     * @param cols  Numero de columnas de la matriz
     * @param type  Tipo de la matriz en la forma CV_<bit depth><S|U|F>C<number of channels>
     * @return Objeto de la clase Mat
     */
    public static Mat CreateMat(int rows, int cols, int type){
        //Mat mmat = CreateMatHeader(rows, cols, type);
        return cxcore.cvCreateMat(rows, cols, type);
    }

    /**
     * Inicializa el objeto Mat pero no prepara el espacio para la matriz
     * @see <a href="http://opencv.willowgarage.com/documentation/c/core_operations_on_arrays.html#index-8605">Mas Info</a>
     * @param rows  Numero de filas de la matriz
     * @param cols  Numero de columnas de la matriz
     * @param type  Tipo de la matriz en la forma CV_<bit depth><S|U|F>C<number of channels>
     * @return Objeto de la clase Mat
     */
    public static Mat CreateMatHeader(int rows, int cols, int type){
        return cxcore.cvCreateMatHeader(rows, cols, type);
    }

    //----cvScalar
    /**
     * Contenedor de 1,2,3 o 4 variables tipo double
     * @see <a href="http://opencv.willowgarage.com/documentation/c/core_basic_structures.html#index-8474">Mas Info</a>
     */
    public static class Scalar extends Structure
            implements Structure.ByReference
    {
        public double val[] = new double[4];
        public Scalar(){
            val[0] = 0.0;
            val[1] = 0.0;
            val[2] = 0.0;
            val[3] = 0.0;
        }
        public Scalar(double v){
            val[0] = v;
            val[1] = v;
            val[2] = v;
            val[3] = v;
        }
        public Scalar(double v0, double v1,double v2, double v3){
            val[0] = v0;
            val[1] = v1;
            val[2] = v2;
            val[3] = v3;
        }
    }

    //----IplImage
    /**
     * Estructura IPL image x64bits
     * @see <a href="http://opencv.willowgarage.com/documentation/c/core_basic_structures.html#index-8479">Mas Info</a>
     */
    public static class IplImage extends Structure
            implements Structure.ByReference
    {
        public IplImage(Pointer ptr)
        {            
            useMemory(ptr,0);
            read();
        }

        public int  nSize;
        public int  ID;
        public int  nChannels;
        public int  alphaChannel;
        public int  depth;
        public byte colorModel0;
        public byte colorModel1;
        public byte colorModel2;
        public byte colorModel3;
        public byte channelSeq0;
        public byte channelSeq1;
        public byte channelSeq2;
        public byte channelSeq3;
        public int  dataOrder;
        public int  origin;
        public int  align;
        public int  width;
        public int  height;
        public long roi;
        public long maskROI;
        public long imageId;
        public long tileInfo;
        public int  imageSize;
        public long imageData;
        public int  widthStep;
        public int  BorderMode0;
        public int  BorderMode1;
        public int  BorderMode2;
        public int  BorderMode3;
        public int  BorderConst0;
        public int  BorderConst1;
        public int  BorderConst2;
        public int  BorderConst3;
        public long imageDataOrigin;
    };

    //------------------------------------------
    //--- FUNCIONES OPENCV
    //------------------------------------------
    /**
     * Crea la estructura para una imagen y prepara el espacio necesario en memoria
     * @see <a href="http://opencv.willowgarage.com/documentation/c/core_operations_on_arrays.html#index-8602">Mas Info</a>
     * @param width Ancho de la imagen
     * @param heigth Alto de la imagen
     * @param depth Profundidad en bits de la imagen
     * @param channels Numero de canales de la imagen
     * @return Pointer a la imagen
     */
    public static Pointer createImage(int width, int heigth, int depth, int channels)
    {                
        Size size = new Size(width,heigth);
        return cxcore.cvCreateImage(size, depth, channels);
    }

    /**
     * Convierte una imagen de un espacio de color a otro.
     * @see <a href="http://opencv.willowgarage.com/documentation/c/miscellaneous_image_transformations.html#cvCvtColor">Mas Info</a>
     * @param src Imagen Fuente
     * @param dst Imagen Destino (con diferente numero de canales que la Imagen Fuente)
     * @param code Conversion de color a realizar
     */
    public static void cvtColor(Pointer src, Pointer dst, int code)
    {
        cv.cvCvtColor(src,dst,code);
    }

    /**
     * Muestra una imagen en una ventana
     * @see <a href="http://opencv.willowgarage.com/documentation/c/user_interface.html#cvShowImage">Mas Info</a>
     * @param name  Nombre de la ventana
     * @param image Imagen a mostrar
     */
    public static void showImage(String name, Pointer image)
    {
        highgui.cvShowImage(name,image);
    }
    
    /**
     * Muestra una imagen en una ventana
     * @see <a href="http://opencv.willowgarage.com/documentation/c/user_interface.html#cvShowImage">Mas Info</a>
     * @param name  Nombre de la ventana
     * @param image Imagen a mostrar
     */
    public static void Resize(Pointer src, Pointer dst, int interpolation)
    {
        cv.cvResize(src, dst, interpolation);
    }


    /**
     * Destruye una ventana
     * @see <a href="http://opencv.willowgarage.com/documentation/c/user_interface.html#index-1641">Mas Info</a>
     * @param name Nombre de la ventana a eliminar
     */
    public static void DestroyWindow(String name){
        highgui.cvDestroyWindow(name);
    }

    /**
     * Convierte un arreglo a otro mediante una trasformacion lineal Y = shift + (x*scale)
     * @see <a href="http://opencv.willowgarage.com/documentation/c/core_operations_on_arrays.html#index-8596">Mas Info</a>
     * @param src Array de origen
     * @param dst Array de destino
     * @param scale Factor de escala
     * @param shift Corrimiento
     */
    public static void ConvertScale(Pointer src, Pointer dst, double scale, double shift){
        cxcore.cvConvertScale(src, dst, scale, shift);
    }

    /**
     * Realiza la diferencia elemento por elemento entre dos Array
     * @see <a href="http://opencv.willowgarage.com/documentation/c/core_operations_on_arrays.html#cvSub">Mas Info</a>
     * @param src1 Array Sustraendo
     * @param src2 Array Sustractor
     * @param dst  Array de Destino
     * @param mask Mascara (opcional)
     */
    public static void Sub(Pointer src1, Pointer src2, Pointer dst, Pointer mask){
        cxcore.cvSub(src1, src2, dst, mask);
    }

    /**
     * Realiza una copia completa de una imagen incluyendo encabezado, datos y regiones de interes (ROI)
     * @see <a href="http://opencv.willowgarage.com/documentation/c/core_operations_on_arrays.html#index-8590">Mas Info</a>
     * @param image Imagen a Clonar
     * @return Nueva Imagen
     */
    public static Pointer CloneImage(Pointer image){
        return cxcore.cvCloneImage(image);
    }

    /**
     * Libera la memoria usada por una imagen
     * @see <a href="http://opencv.willowgarage.com/documentation/c/core_operations_on_arrays.html#cvReleaseImage">Mas Info</a>
     * @param image Imagen a liberar
     */
    public static void ReleaseImage(Pointer image){
        cxcore.cvReleaseImage(image);
    }

    /**
     * Limpia los datos de una imagen convirtiendolos en Ceros
     * @see <a href="http://opencv.willowgarage.com/documentation/c/core_operations_on_arrays.html#cvSetZero">Mas Info</a>
     * @param arr Imagen a Limpiar
     */
    public static void SetZero(Pointer arr){
        cxcore.cvSetZero(arr);
    }

    /**
     * Copia un array a otro
     * @see <a href="http://opencv.willowgarage.com/documentation/c/core_operations_on_arrays.html#index-8599">Mas Info</a>
     * @param src Array Original
     * @param dst Array de Destino
     * @param mask Mascara (opcional)
     */
    public static void Copy(Pointer src, Pointer dst, Pointer mask){
        cxcore.cvCopy(src, dst, mask);
    }

    /**
     * Divide la imagen en canales
     * @see <a href="http://opencv.willowgarage.com/documentation/c/core_operations_on_arrays.html#index-8699">Mas Info</a>
     * @param src   Imagen Original con canales RGB o RGBA
     * @param dst0  Imagen destino canal 0
     * @param dst1  Imagen destino canal 1
     * @param dst2  Imagen destino canal 2
     * @param dst3  Imagen destino canal 3
     */
    public static void Split(Pointer src, Pointer dst0, Pointer dst1, Pointer dst2, Pointer dst3){
        cxcore.cvSplit(src, dst0, dst1, dst2, dst3);
    }

    /**
     * Aplica un umbral ajustado de acuerdo al parametro <b>thresholdType</b>, a un array
     * @see <a href="http://opencv.willowgarage.com/documentation/c/miscellaneous_image_transformations.html#index-1408">Mas Info</a>
     * @param src Array Original
     * @param dst Array de Destino
     * @param threshold valor del umbral
     * @param maxValue Maximo valor a usar con el tipo <b>CV_THRESH_BINARY</b> y <b>CV_THRESH_BINARY_INV</b>
     * @param thresholdType Tipo de Umbral: <b>CV_THRESH_BINARY, CV_THRESH_BINARY_INV, CV_THRESH_TRUNC, CV_THRESH_TOZERO, CV_THRESH_TOZERO_INV</b>
     * @return Valor del Umbral aplicado dependiendo del tipo de Umbral
     */
    public static double Threshold(Pointer src, Pointer dst, double threshold, double maxValue, int thresholdType){
        return cv.cvThreshold(src, dst, threshold, maxValue, thresholdType);
    }

    /**
     * Retorna un elemento especifico de una matriz
     * @see <a href="http://opencv.willowgarage.com/documentation/c/core_operations_on_arrays.html#cvGetReal2D">Mas Info</a>
     * @param arr   Matriz
     * @param idx0  Coordenada X
     * @param idx1  Coordenada Y
     * @return Valor del elemento
     */
    public static double GetReal2D(Pointer arr, int idx0, int idx1){
        return cxcore.cvGetReal2D(arr, idx0, idx1);
    }
    /**
     * Establece un valor a un elemento especifico de una matriz
     * @see <a href="http://opencv.willowgarage.com/documentation/c/core_operations_on_arrays.html#cvSetReal2D">Mas Info</a>
     * @param arr   Matriz
     * @param idx0  Coordenada X
     * @param idx1  Coordenada Y
     * @param value Nuevo valor
     */
    public static void SetReal2D(Pointer arr, int idx0, int idx1, double value){
        cxcore.cvSetReal2D(arr, idx0, idx1, value);
    }

    /**
     * Integra imagenes de un canal en los canales de una imagen multicanal
     * @see <a href="http://opencv.willowgarage.com/documentation/c/core_operations_on_arrays.html#index-8656">Mas Info</a>
     * @param src0  Imagen de origen canal 0
     * @param src1  Imagen de origen canal 1
     * @param src2  Imagen de origen canal 2
     * @param src3  Imagen de origen canal 3
     * @param dst   Imagen destino
     */
    public static void Merge(Pointer src0, Pointer src1, Pointer src2, Pointer src3, Pointer dst){
        cxcore.cvMerge(src0, src1, src2, src3, dst);
    }
    
    /**
     * Convoluciona una imagen con un Kernel
     * @see <a href="http://opencv.willowgarage.com/documentation/c/image_filtering.html#index-1392">Mas Info</a>
     * @param src   Imagen Original
     * @param dst   Imagen Destino
     * @param kernel Kernel
     * @param x Coordenada X de la posición central del kernel
     * @param y Coordenada Y de la posición central del kernel
     */
    public static void Filter2D(Pointer src, Pointer dst, Mat kernel, int x, int y){
        cv.cvFilter2D(src, dst, kernel, x, y);
    }

    /**
     * Establece todos los elementos de un array con el valor especificado
     * @param arr Matriz Original
     * @param value Valor a establecer
     * @param mask Mascara (opcional)
     */
    public static void Set(Mat arr, Scalar value, Pointer mask){
        cxcore.cvSet(arr, value, mask);
    }

    /**
     * Suaviza la imagen de acuerdo al tipo de suavizado <b>smoothtype</b>
     * @param src   Imagen Original
     * @param dst   Imagen Destino
     * @param smoothtype Tipo de Suavizado: <b>CV_BLUR_NO_SCALE, CV_BLUR, CV_GAUSSIAN, CV_MEDIAN, CV_BILATERAL</b>
     * @param param1, param2, param3, param4
     * @see <a href="http://opencv.willowgarage.com/documentation/c/image_filtering.html#cvSmooth">Mas Info</a>
     *
     */
    public static void smooth(Pointer src, Pointer dst, int smoothtype, int param1, int param2, double param3, double param4){
        cv.cvSmooth(src, dst, smoothtype, param1, param2, param3, param4);
    }

    /**
     * Calcula el promedio de los elementos de un array
     * @see <a href="http://opencv.willowgarage.com/documentation/c/core_operations_on_arrays.html#index-8584">Mas Info</a>
     * @param arr Imagen Original
     * @param mask Imagen Destino
     * @return Valor del promedio
     */
    public static Scalar avg(Pointer arr, Pointer mask){
        return cxcore.cvAvg(arr, mask);
    }

    /**
     * Calcula el promedio y la desviación estándar de los elementos de un array
     *  @see <a href="http://opencv.willowgarage.com/documentation/c/core_operations_on_arrays.html#cvAvgSdv">Mas Info</a>
     * @param arr Imagen Original
     * @param mean Valor del promedio
     * @param stdDev Valor de la desviación estándar
     * @param mask  Mascara (opcional)
     */
    public static void AvgSdv(Pointer arr, Scalar mean, Scalar stdDev, Pointer mask){
        cxcore.cvAvgSdv(arr, mean, stdDev, mask);
    }

    /**
     * Realiza la diferencia absoluta elemento por elemento entre dos Array
     * @see <a href="http://opencv.willowgarage.com/documentation/c/core_operations_on_arrays.html#index-8577">Mas Info</a>
     * @param src1 Array Sustraendo
     * @param src2 Array Sustractor
     * @param dst  Array de Destino
     */
    public static void AbsDiff(Pointer src1, Pointer src2, Pointer dst){
        cxcore.cvAbsDiff(src1, src2, dst);
    }

    /**
     * Realiza la diferencia absoluta elemento por elemento entre un Array y un escalar
     * @see <a href="http://opencv.willowgarage.com/documentation/c/core_operations_on_arrays.html#cvAbsDiffS">Mas Info</a>
     * @param src Array Sustraendo
     * @param dst Array de Destino
     * @param value Valor Sustractor
     */
    public static void AbsDiffS(Pointer src, Pointer dst, Scalar value){
        cxcore.cvAbsDiffS(src, dst, value);
    }

    /**
     * Realiza la adición elemento por elemento entre dos Array
     * @see <a href="http://opencv.willowgarage.com/documentation/c/core_operations_on_arrays.html#index-8579">Mas Info</a>
     * @param src1 Array Sumando
     * @param src2 Array Sumando
     * @param dst  Array de Destino
     * @param mask Mascara (opcional)
     */
    public static void Add(Pointer src1, Pointer src2, Pointer dst, Pointer mask){
        cxcore.cvAdd(src1, src2, dst, mask);
    }

    /**
     * Realiza la adición elemento por elemento entre un Array y un escalar
     * @param src Array Sumando
     * @param value Valor Sumando
     * @param dst  Array de Destino
     * @param mask Mascara (opcional)
     */
    public static void AddS(Pointer src, Scalar value, Pointer dst, Pointer mask){
        cxcore.cvAddS(src, value, dst, mask);
    }  


    public static int SaveImage(String filename, Pointer image){
        return highgui.cvSaveImage(filename, image);
    }
    public static Pointer LoadImage(String filename, int iscolor){
        return highgui.cvLoadImage(filename, iscolor);
    }
    
    public static void PyrUp( Pointer src, Pointer dst, int filter )
    {
        cv.cvPyrUp(src, dst, filter);
    }
    public static void PyrDown( Pointer src, Pointer dst, int filter )
    {
        cv.cvPyrDown(src, dst, filter);
    }
    public static void Set2D(Pointer arr, int idx0, int idx1, Scalar value)
    {
        cxcore.cvSet2D(arr, idx0, idx1, value);
    }

    public static double Invert(Pointer src, Pointer dst, int method)
    {
        return cxcore.cvInvert(src, dst, method);
    }
    
    public static Scalar CV_RGB(int R, int G, int B)
    {
        return new Scalar(R, G, B, 0);
    }

    public static Pointer createCameraCapture(int index)
    {
       Pointer capPtr = highgui.cvCreateCameraCapture(index);
       if(capPtr!=null)
       {
            setCaptureProperty(capPtr,CV_CAP_PROP_CONVERT_RGB,1);            
       }

       return capPtr;
    }   

    public static Pointer CreateFileCapture(String filename){
        return highgui.cvCreateFileCapture(filename);
    }

    public static void releaseCapture(Pointer capute)
    {
         highgui.cvReleaseCapture(capute);
    }
   
    public static int setCaptureProperty(Pointer capture,int propertyId,double value)
    {
        return highgui.cvSetCaptureProperty(capture,propertyId,value);
    }
    public static double GetCaptureProperty(Pointer capture,int propertyId)
    {
        return highgui.cvGetCaptureProperty(capture,propertyId);
    }

    public static int waitKey(int delay)
    {
       return highgui.cvWaitKey(delay);
    }
    
   
    public static Pointer queryFrame(Pointer capture)
    {
        return highgui.cvQueryFrame(capture);
    }

    public static int CV_MAKETYPE(int depth, int cn){
        return (depth & ((1<<3)-1)) + ((cn - 1) << 3);
    }
    

    public static int CV_LU = 0;
    public static int CV_SVD = 1;
    public static int CV_SVD_SYM = 2;

    public static int CV_GAUSSIAN_5x5 = 7;

    public static int CV_8U = 0;
    public static int CV_8S  = 1;
    public static int CV_16U = 2;
    public static int CV_16S = 3;
    public static int CV_32S = 4;
    public static int CV_32F = 5;
    public static int CV_64F = 6;

    public static int CV_32FC1 = CV_MAKETYPE(CV_32F,1);

    public static int CV_LOAD_IMAGE_UNCHANGED = -1;
    public static int CV_LOAD_IMAGE_GRAYSCALE = 0;
    public static int CV_LOAD_IMAGE_COLOR = 1;
    public static int CV_LOAD_IMAGE_ANYDEPTH = 2;
    public static int CV_LOAD_IMAGE_ANYCOLOR = 4;

    public static int CV_BLUR_NO_SCALE = 0;
    public static int CV_BLUR = 1;
    public static int CV_GAUSSIAN = 2;
    public static int CV_MEDIAN = 3;
    public static int CV_BILATERAL = 4;
    // Copy to cxtypes.h
    public static int IPL_DEPTH_SIGN = 0x80000000;

    public static int IPL_DEPTH_1U   =  1;
    public static int IPL_DEPTH_8U   =  8;
    public static int IPL_DEPTH_16U  = 16;
    public static int IPL_DEPTH_32F  = 32;

    public static int IPL_DEPTH_8S  = (IPL_DEPTH_SIGN| 8);
    public static int IPL_DEPTH_16S = (IPL_DEPTH_SIGN|16);
    public static int IPL_DEPTH_32S = (IPL_DEPTH_SIGN|32);

    // Copy to cv.h
    public static int  CV_BGR2BGRA    = 0;
    public static int  CV_RGB2RGBA    = CV_BGR2BGRA;

    public static int  CV_BGRA2BGR    = 1;
    public static int  CV_RGBA2RGB    = CV_BGRA2BGR;

    public static int  CV_BGR2RGBA    = 2;
    public static int  CV_RGB2BGRA    = CV_BGR2RGBA;

    public static int  CV_RGBA2BGR    = 3;
    public static int  CV_BGRA2RGB    = CV_RGBA2BGR;

    public static int  CV_BGR2RGB     = 4;
    public static int  CV_RGB2BGR     = CV_BGR2RGB;

    public static int  CV_BGRA2RGBA   = 5;
    public static int  CV_RGBA2BGRA   = CV_BGRA2RGBA;

    public static int  CV_BGR2GRAY    = 6;
    public static int  CV_RGB2GRAY    = 7;
    public static int  CV_GRAY2BGR    = 8;
    public static int  CV_GRAY2RGB    = CV_GRAY2BGR;
    public static int  CV_GRAY2BGRA   = 9;
    public static int  CV_GRAY2RGBA   = CV_GRAY2BGRA;
    public static int  CV_BGRA2GRAY   = 10;
    public static int  CV_RGBA2GRAY   = 11;

    public static int  CV_BGR2BGR565  = 12;
    public static int  CV_RGB2BGR565  = 13;
    public static int  CV_BGR5652BGR  = 14;
    public static int  CV_BGR5652RGB  = 15;
    public static int  CV_BGRA2BGR565 = 16;
    public static int  CV_RGBA2BGR565 = 17;
    public static int  CV_BGR5652BGRA = 18;
    public static int  CV_BGR5652RGBA = 19;

    public static int  CV_GRAY2BGR565 = 20;
    public static int  CV_BGR5652GRAY = 21;

    public static int  CV_BGR2BGR555  = 22;
    public static int  CV_RGB2BGR555  = 23;
    public static int  CV_BGR5552BGR  = 24;
    public static int  CV_BGR5552RGB  = 25;
    public static int  CV_BGRA2BGR555 = 26;
    public static int  CV_RGBA2BGR555 = 27;
    public static int  CV_BGR5552BGRA = 28;
    public static int  CV_BGR5552RGBA = 29;

    public static int  CV_GRAY2BGR555 = 30;
    public static int  CV_BGR5552GRAY = 31;

    public static int  CV_BGR2XYZ     = 32;
    public static int  CV_RGB2XYZ     = 33;
    public static int  CV_XYZ2BGR     = 34;
    public static int  CV_XYZ2RGB     = 35;

    public static int  CV_BGR2YCrCb   = 36;
    public static int  CV_RGB2YCrCb   = 37;
    public static int  CV_YCrCb2BGR   = 38;
    public static int  CV_YCrCb2RGB   = 39;

    public static int  CV_BGR2HSV     = 40;
    public static int  CV_RGB2HSV     = 41;

    public static int  CV_BGR2Lab     = 44;
    public static int  CV_RGB2Lab     = 45;

    public static int  CV_BayerBG2BGR = 46;
    public static int  CV_BayerGB2BGR = 47;
    public static int  CV_BayerRG2BGR = 48;
    public static int  CV_BayerGR2BGR = 49;

    public static int  CV_BayerBG2RGB = CV_BayerRG2BGR;
    public static int  CV_BayerGB2RGB = CV_BayerGR2BGR;
    public static int  CV_BayerRG2RGB = CV_BayerBG2BGR;
    public static int  CV_BayerGR2RGB = CV_BayerGB2BGR;

    public static int  CV_BGR2Luv     = 50;
    public static int  CV_RGB2Luv     = 51;
    public static int  CV_BGR2HLS     = 52;
    public static int  CV_RGB2HLS     = 53;

    public static int  CV_HSV2BGR     = 54;
    public static int  CV_HSV2RGB     = 55;

    public static int  CV_Lab2BGR     = 56;
    public static int  CV_Lab2RGB     = 57;
    public static int  CV_Luv2BGR     = 58;
    public static int  CV_Luv2RGB     = 59;
    public static int  CV_HLS2BGR     = 60;
    public static int  CV_HLS2RGB     = 61;

    public static int  CV_COLORCVT_MAX  = 100;

    // Copy to highgui.h
    public static int CV_CAP_PROP_POS_MSEC      = 0;
    public static int CV_CAP_PROP_POS_FRAMES    = 1;
    public static int CV_CAP_PROP_POS_AVI_RATIO = 2;
    public static int CV_CAP_PROP_FRAME_WIDTH   = 3;
    public static int CV_CAP_PROP_FRAME_HEIGHT  = 4;
    public static int CV_CAP_PROP_FPS           = 5;
    public static int CV_CAP_PROP_FOURCC        = 6;
    public static int CV_CAP_PROP_FRAME_COUNT   = 7;
    public static int CV_CAP_PROP_FORMAT        = 8;
    public static int CV_CAP_PROP_MODE          = 9;
    public static int CV_CAP_PROP_BRIGHTNESS    = 10;
    public static int CV_CAP_PROP_CONTRAST      = 11;
    public static int CV_CAP_PROP_SATURATION    = 12;
    public static int CV_CAP_PROP_HUE           = 13;
    public static int CV_CAP_PROP_GAIN          = 14;
    public static int CV_CAP_PROP_EXPOSURE      = 15;
    public static int  CV_CAP_PROP_CONVERT_RGB  = 16;
    public static int  CV_CAP_PROP_WHITE_BALANCE =17;
    public static int  CV_CAP_PROP_RECTIFICATION =18;
}
//--------------------------------------------------